package com.hl233.framework;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
/**
 * @author 张振强15065206763
 * @create 2024-09-07
 */
public class RabbitConnectionCheck {

    public static void main(String[] args) {
        // 创建连接工厂
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("192.168.84.130"); // 设置RabbitMQ服务器的地址
        factory.setPort(5673); // 设置端口号
        factory.setUsername("admin"); // 设置用户名
        factory.setPassword("root"); // 设置密码
//        factory.set

        try (Connection connection = factory.newConnection(); ) {
            // 如果连接成功，将会执行到这里
            System.out.println("RabbitMQ connection is valid.");
        } catch (Exception e) {
            // 如果连接失败，将会捕获异常
            System.out.println("RabbitMQ connection is not valid: " + e.getMessage());
        }
    }
}